package com.delay.queue.delayedqueue.redisson;

//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//import org.redisson.api.RedissonClient;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.stereotype.Component;

/**
 * @author gxing
 * @desc
 * @date 2021/3/12
 */
//@Component
//public class RedisDelayQueueListener implements CommandLineRunner {
//    private static final Logger logger = LogManager.getLogger(RedisDelayQueueListener.class);
//
//    @Autowired
//    RedisDelayedQueueManager redisDelayedQueueManager;
//    @Autowired
//    private RedissonClient redissonClient;
//
//    @Override
//    public void run(String... args) throws Exception {
//        logger.info("===============延时队列监听器启动==============");
        //添加需要延迟的DTO
//        DelayMessage message1 = new DelayMessage(1, "value" + 1);
//        DelayMessage message8 = new DelayMessage(8, "value" + 8);
//        DelayMessage message9 = new DelayMessage(9, "value" + 9);
//        DelayMessage message3 = new DelayMessage(3, "value" + 3);
//        DelayMessage message6 = new DelayMessage(6, "value" + 6);
//        redisDelayedQueue.addQueue(message1, 1, TimeUnit.SECONDS, "DelayMessage");
//        redisDelayedQueue.addQueue(message8, 8, TimeUnit.SECONDS, "DelayMessage");
//        redisDelayedQueue.addQueue(message9, 9, TimeUnit.SECONDS, "DelayMessage");
//        redisDelayedQueue.addQueue(message3, 3, TimeUnit.SECONDS, "DelayMessage");
//        redisDelayedQueue.addQueue(message6, 6, TimeUnit.SECONDS, "DelayMessage");
        //监听延迟队列
//        DelayedTaskListener<String> delayedTaskListener = new DelayedTaskListener<String>() {
//            @Override
//            public void invoke(String delayMessage) {
//                //这里调用你延迟之后的代码
//                System.out.println(delayMessage);
//            }
//        };
//        redisDelayedQueueManager.take("DelayMessage", delayedTaskListener);
//    }
//}
